#!/usr/bin/env python
######################################################################
##
## Copyright (C) 2006,  Simon Kagstrom
##
## Filename:	  cibyl-generate-syscall-db
## Author:		Simon Kagstrom <ska@bth.se>
## Description:   Generate Java and C syscall constants
##
## $Id: cibyl-generate-syscall-db 13549 2007-02-09 21:19:12Z ska $
##
######################################################################
import sys, re, getopt
sys.path.append('%s/python/' % sys.path[0])
from Cibyl.SyscallHandling.syscallgenerator import *
from optparse import OptionParser

usage = """Usage: cibyl-generate-syscall-db [-o outfile] dir set1 [set2 ...]

Generate a database of system call definitions from the directory
'dir' consisting of the syscall sets 'set1', 'set2' etc. The sets are
contained within the directory 'dir', e.g., syscalls/j2me.
"""
parser = OptionParser(usage = usage)
parser.add_option("-o", "--outfile", dest="outfile", default='./cibyl-syscalls.db',
				  help="Write output to outfile instead of ./cibyl-syscalls.db",
				  metavar="OUTFILE")

(options, args) = parser.parse_args()

if len(args) < 2:
	parser.error("incorrect number of arguments. Invoke with --help for arguments")

dirname = args[0]
syscallSets = args[1:]

f = SyscallDatabaseGenerator(dirname, syscallSets, options.outfile)
f.run()
